<template>
	<view class="Select" @click="go">
		<view  class="SelectView">
			{{title}}
			<svg t="1600913622892" class="icon SelectIcon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1688"
			 width="10" height="10" >
				<path d="M865.416 382.669l-285.278 404.032c-30.568 42.573-106.991 42.573-137.559 0l-286.134-404.032c-30.568-42.573-8.649-112.937 52.489-112.937L813.786 269.732c61.13599999 0 82.2 70.364 51.629 112.937z"
				 p-id="1689" fill="#ffffff"></path>
			</svg>
		</view>
		<ul v-show="show" class="Select-ul">
			<li @click="getLi(i)" v-for="(item,i) in arr" :key="i"  >{{item}}</li>
		</ul>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'深圳'	,
				show:false,
				arr:['深圳','惠州','哈尔滨','天津']
				
			};
		},
		created() {
			uni.getLocation({
			    type: 'wgs84',
				geocode:true,
			    success: function (res) {
			        console.log('当前位置的城市：' + res.address);
			    },
				fail:function(res){
					console.log('fail',res)
				}
			});
		},
		methods: {
			showUl(){
				this.show = !this.show
			},
			getLi(i){
				this.title = this.arr[i];
				this.show = !this.show;
			},
			go(){
				uni.navigateTo({
				    url: `../../pages/location/location?title=${this.title}`,
					fail:function(res){
						console.log(res)
					}
				});
			}
		}
	}
</script>

<style>
	.SelectView{
		max-width: 100px;
		overflow: hidden; 
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.SelectIcon{
		margin:0 5px;
	}
	.Select{
		position: relative;
		color: #FFFFFF;
		font-size: 16px;
	}
	.Select-ul{
		background: #FFFFFF;
		color: #000000;
		z-index: 999;
		position: absolute;
		left: -17px;
		top: 32px;
		padding-left: 0px;
		list-style:none;
		width: 70px;
		text-align: center;
	}
</style>
